package com.zm.demo.shoppingmall.common.util;

import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/27 14:02
 */
@Slf4j
public class OKHttpUtil {

    final static OkHttpClient okHttpClient = new OkHttpClient();

//    final static Logger okHttpClient = new OkHttpClient();

    public static Object get(String url){

        Request request = new Request.Builder().url(url).get().build();
        try (Response response = okHttpClient.newCall(request).execute()) {
            return response.body().string();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
}
